package com.ruiya.staging.goods.core.model;

import com.ruiya.staging.goods.core.constants.ErrorCodeEnum;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class RestResponse<T> {
    private String code;
    private String msg;
    private String tid;
    private T data;

    public RestResponse(ErrorCodeEnum errorCode, String tid) {
        this(errorCode.getCode(), errorCode.getMsg(), tid, null);
    }

    public RestResponse(String code, String msg, String tid) {
        this(code, msg, tid, null);
    }

    public RestResponse(T data) {
        this(ErrorCodeEnum.OK.getCode(), null, null, data);
    }

    public RestResponse(T data, String tid){
        this(ErrorCodeEnum.OK.getCode(), null, tid, data);
    }

}
